"""ARM cross compilation toolchains for bazel"""

module(
    name = "toolchains_arm_gnu",
    version = "0.0.1",
    compatibility_level = 1,
)

bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_cc", version = "0.0.9")

arm_toolchain = use_extension("@toolchains_arm_gnu//:extensions.bzl", "arm_toolchain")

# NOTE: It's important that we update these versions whenever a new toolchain
# version is added--otherwise the Minimum Selected Version algorithm in the
# module extension will select the version here if a consumer attempts to use
# the newer toolchain.
arm_toolchain.arm_none_eabi(version = "13.2.1")
use_repo(
    arm_toolchain,
    "arm_none_eabi",
    "arm_none_eabi_darwin_arm64",
    "arm_none_eabi_darwin_x86_64",
    "arm_none_eabi_linux_aarch64",
    "arm_none_eabi_linux_x86_64",
    "arm_none_eabi_windows_x86_64",
)
arm_toolchain.arm_none_linux_gnueabihf(version = "13.2.1")
use_repo(
    arm_toolchain,
    "arm_none_linux_gnueabihf",
    "arm_none_linux_gnueabihf_linux_aarch64",
    "arm_none_linux_gnueabihf_linux_x86_64",
    "arm_none_linux_gnueabihf_windows_x86_64",
)

# DEV ONLY (not needed for release)
bazel_dep(name = "aspect_bazel_lib", version = "2.0.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

register_toolchains(
    "@arm_none_eabi//toolchain:all",
    "@arm_none_linux_gnueabihf//toolchain:all",
    dev_dependency = True,
)
